/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pbs.daos;

import br.com.pbs.exeptions.BancoExeption;
import br.com.pbs.factory.Factory;
import br.com.pbs.interfaces.IEnderecoDao;
import br.com.pbs.interfaces.IFactoryPessoa;
import br.com.pbs.pojos.Endereco;
import br.com.pbs.pojos.Responsavel;
import java.util.List;

/**
 *
 * @author Luiz Segundo
 */
public class ResponsavelDao extends PessoaDao {
      

        public Responsavel verifica(Responsavel valida) throws BancoExeption {
                IFactoryPessoa fabrica = new Factory();
                IEnderecoDao endereco = fabrica.getEnderecoDao();
                List<Endereco> e = null;
                if (valida.getEnderecos() != null) {
                        e = endereco.buscaPorAtributoString("rua", valida.getEnderecos().getRua(), new Endereco());
                        if (e == null && !e.get(1).equals(valida.getEnderecos())) {
                                endereco.save(valida.getEnderecos());
                        }
                }

                return valida;
        }
}
